package view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import model.User;

public class MainFrame extends JFrame implements ActionListener {
	JButton jbtupdate,jbtcancell;
	JLabel jlbuserid,jlbpassword,jlbusername;
	JTextField jtfuserid,jtfpassword,jtfusername;
	
	
     MainFrame(User user){
    	 	setTitle("用户服务");
    	   	setSize(220,210);
    	   	setLocationRelativeTo(null);
    	   	setResizable(false);
    	   	setLayout(null);
    	   	jlbuserid=new JLabel("用户账号");
    	   	jlbpassword=new JLabel("用户密码");
    	   	jlbusername=new JLabel("用户名称");
    	   	
    	   	jbtupdate=new JButton("更新信息");
    	   	jbtcancell=new JButton("退出");
    	   	
    	   	jtfuserid=new JTextField(20);
    	   	jtfpassword=new JTextField(20);
    	   	jtfusername=new JTextField(20);
    	   	
    	   	jlbuserid.setBounds(20, 20, 60, 20);  add(jlbuserid); 
    	   	jlbpassword.setBounds(20, 70, 60, 20); add(jlbpassword);
    	   	jlbusername.setBounds(20, 120, 60, 20);  add(jlbusername);
    	   	
    	   	jtfuserid.setBounds(80, 20, 110, 20);  add(jtfuserid);
    	   	jtfpassword.setBounds(80, 70, 110, 20);  add(jtfpassword);
    	   	jtfusername.setBounds(80, 120, 110, 20);add(jtfusername);
    	   	
    	   	jtfuserid.setEditable(false);
    	   	jtfpassword.setEditable(false);
    	   	jtfusername.setEditable(false);
    	   	
    	   	jbtupdate.setBounds(20, 150, 90, 20); add(jbtupdate); jbtupdate.addActionListener(this);
    	   	jbtcancell.setBounds(120, 150, 90, 20);add(jbtcancell);jbtcancell.addActionListener(this);
    	   	
    	   	setVisible(true);
     }
    
	
	public void actionPerformed(ActionEvent e) {
		if(e.getSource()==jbtcancell){
			dispose();
		}
		
		if(e.getSource()==jbtupdate){		
			dispose();
    	   new UpdateDialog();
    	   	
    	   	
		}
		
		
	}
     
     
}
